package httpserver

type ServerOps = func(*HttpServer)

const HealthUrl = "/health"
const RequestIdName = "RequestId"

//default server config
var defaultServerConfig = &ServerConfig{
	requestId:      true,
	requestIdField: RequestIdName,
	healthCheck:    true,
	healthPath:     HealthUrl,
	acceptOptions:  true,
}

type ServerConfig struct {
	requestId      bool
	requestIdField string

	//健康检查配置
	healthCheck bool
	healthPath  string

	//对options请求自动处理
	acceptOptions bool
}

var WithOpsRequestId = func(requestIdField string) ServerOps {
	return func(server *HttpServer) {
		server.config.requestId = requestIdField != ""
		server.config.requestIdField = requestIdField
	}
}

var WithOpsHealthCheck = func(add bool, health string) ServerOps {
	return func(server *HttpServer) {
		server.config.healthCheck = add
		server.config.healthPath = health
	}
}

var WithOpsAcceptOptions = func(accept bool) ServerOps {
	return func(server *HttpServer) {
		server.config.acceptOptions = accept
	}
}
